package com.gzck.gzck_verson2.controller;


import com.gzck.gzck_verson2.pojo.GSensorFormulatypeInfo;
import com.gzck.gzck_verson2.service.IGSensorFormulatypeInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 计算公式库 前端控制器
 * </p>
 *
 * @author 任永辉
 * @since 2024-01-27
 */
@RestController
@RequestMapping("/g-sensor-formulatype-info")
public class GSensorFormulatypeInfoController {

    @Autowired
    private IGSensorFormulatypeInfoService sensorFormulatypeInfoService;

    // 添加传感器公式类型信息
    @PostMapping("/add")
    public boolean addSensorFormulatypeInfo(@RequestBody GSensorFormulatypeInfo sensorFormulatypeInfo) {
        return sensorFormulatypeInfoService.save(sensorFormulatypeInfo);
    }

    // 删除传感器公式类型信息
    @DeleteMapping("/delete/{id}")
    public boolean deleteSensorFormulatypeInfo(@PathVariable Long id) {
        return sensorFormulatypeInfoService.removeById(id);
    }

    // 更新传感器公式类型信息
    @PutMapping("/update")
    public boolean updateSensorFormulatypeInfo(@RequestBody GSensorFormulatypeInfo sensorFormulatypeInfo) {
        return sensorFormulatypeInfoService.updateById(sensorFormulatypeInfo);
    }

    // 查询单个传感器公式类型信息
    @GetMapping("/{id}")
    public GSensorFormulatypeInfo getSensorFormulatypeInfo(@PathVariable Long id) {
        return sensorFormulatypeInfoService.getById(id);
    }

    // 查询所有传感器公式类型信息
    @GetMapping("/all")
    public List<GSensorFormulatypeInfo> getAllSensorFormulatypeInfos() {
        return sensorFormulatypeInfoService.list();
    }
}
